package cc.jq1024.domain.activity.event;

import cc.jq1024.types.event.BaseEvent;
import cc.jq1024.types.snow.SnowflakeIdGenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;


/**
 * @Author: jia-qiang ljq1024.cc
 * @desc: 活动sku库存清空消息
 * @Date: 2024-04-24-19:56
 */
@Component
public class ActivitySkuStockZeroMessageEvent extends BaseEvent<Long> {

    @Value("${spring.rabbitmq.topic.activity_sku_stock.zero}")
    private String topic;

    @Resource
    private SnowflakeIdGenerator snowflakeIdGenerator;

    @Override
    public EventMessage<Long> buildEventMessage(Long sku) {
        return EventMessage.<Long>builder()
                .id(String.valueOf(snowflakeIdGenerator.nextId()))
                .timestamp(new Date())
                .data(sku)
                .build();
    }

    @Override
    public String topic() {
        return topic;
    }

}
